
ERRTRAP(){
    echo "[LINE:$1] Error Command or function exited with status $?"
}

foo(){
    return 1;
}

trap 'ERRTRAP $LINENO' ERR
abc
foo

#trap.sh: line 11: abc: command not found
#[LINE:11] Error Command or function exited with status 127
#[LINE:12] Error Command or function exited with status 1